package com.imooc.order.message;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

import java.util.stream.Stream;

@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.INPUT2)    // 处理完后消息回传的目的地
    public String process(Object message){
        log.info("StreamReceiver: {}",message);

        return "received.";
    }

    @StreamListener(value = StreamClient.INPUT2)
    public void process2(Object message){
        log.info("StreamReceiver2: {}",message);

    }
}
